package com.uphone.kingmall.activity.personal.set;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.china.zhuoyue.R;
import com.kyleduo.switchbutton.SwitchButton;
import com.uphone.kingmall.base.BaseActivity;
import com.uphone.kingmall.utils.SharedPreferencesHelper;

import butterknife.BindView;
import butterknife.OnClick;


/**
 * <pre>
 *     author : 王雨
 *     e-mail : sunzengyan@outlook.com
 *     time   : 2018/07/31
 *     desc   :消息通知设置
 *     version: 1.0
 * </pre>
 */
public class MessageNoticeSetActivity extends BaseActivity {
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.rl_sound)
    SwitchButton rlSound;
    @BindView(R.id.rl_shock)
    SwitchButton rlShock;
    @BindView(R.id.rl_notice)
    SwitchButton rlNotice;

    @Override
    public int getLayoutContentId() {
        return R.layout.kingmall_activity_meassge_notice_set;
    }

    @Override
    public void initView() {
        setStatusBar();
    }

    @Override
    public void initData() {
        if (!TextUtils.isEmpty(SharedPreferencesHelper.getSettingVoice())) {
            rlSound.setChecked(true);
        }
        if (!TextUtils.isEmpty(SharedPreferencesHelper.getSettingShock())) {
            rlShock.setChecked(true);
        }
        if (!TextUtils.isEmpty(SharedPreferencesHelper.getSettingSystem())) {
            rlNotice.setChecked(true);
        }
    }


    @OnClick({R.id.iv_back, R.id.rl_sound, R.id.rl_shock, R.id.rl_notice})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                onBackPressed();
                break;
            case R.id.rl_sound:
                if (rlSound.isChecked()) {
                    SharedPreferencesHelper.saveSettingVoice("1");
                } else {
                    SharedPreferencesHelper.saveSettingVoice("0");
                }
                break;
            case R.id.rl_shock:
                if (rlShock.isChecked()) {
                    SharedPreferencesHelper.saveSettingShock("1");
                } else {
                    SharedPreferencesHelper.saveSettingShock("0");
                }
                break;
            case R.id.rl_notice:
                if (rlNotice.isChecked()) {
                    SharedPreferencesHelper.saveSettingSystem("1");
                } else {
                    SharedPreferencesHelper.saveSettingSystem("0");
                }
                break;
        }
    }
}
